package com.buanalintas.sandals.pos.employee;

import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.sandals.pos.entities.PosMasterEmployee;

public class Employee extends Page {

    private Field employeeId;
    private Field employeeShopId;
    private Field employeeUnitId;
    private Field employeePositionId;
    private Field employeeNik;
    private Field employeeName;
    private Field employeePlaceOfBirth;
    private Field employeeDateOfBirth;
    private Field employeeAddress;
    private Field employeePhone;
    private Field employeeEmail;

    public Employee() {
        setTheClass(PosMasterEmployee.class);

        employeeId = new Field();
        employeeId.setName("employeeId");
        employeeId.setCaption("id");
        employeeId.setListProperties(" align=\"center\" width=\"7%\" nowrap");
        employeeId.setInputProperties(" size=\"20\"");
        getFields().add(employeeId);

        employeeUnitId = new Field();
        employeeUnitId.setName("employeeUnitId");
        employeeUnitId.setCaption("unit");
        employeeUnitId.setDummy(true);
        employeeUnitId.setListProperties(" align=\"left\" width=\"10%\" nowrap");
        employeeUnitId.setInputProperties(" ");
        employeeUnitId.setRequired(true);
        employeeUnitId.setInputType(Field.INPUT_COMBO_BOX);
        getFields().add(employeeUnitId);

        employeeShopId = new Field();
        employeeShopId.setName("employeeShopId");
        employeeShopId.setCaption("shop");
        employeeShopId.setDummy(true);
        employeeShopId.setListProperties(" align=\"left\" width=\"10%\" nowrap");
        employeeShopId.setInputProperties(" ");
        employeeShopId.setRequired(true);
        employeeShopId.setInputType(Field.INPUT_COMBO_BOX);
        getFields().add(employeeShopId);

        employeePositionId = new Field();
        employeePositionId.setName("employeePositionId");
        employeePositionId.setCaption("position");
        employeePositionId.setListProperties(" align=\"left\" width=\"15%\" nowrap");
        employeePositionId.setInputProperties(" ");
        employeePositionId.setInputType(Field.INPUT_COMBO_BOX);
        employeePositionId.setRequired(true);
        getFields().add(employeePositionId);

        employeeNik = new Field();
        employeeNik.setName("employeeNik");
        employeeNik.setCaption("nik");
        employeeNik.setListProperties(" align=\"center\" width=\"8%\" nowrap");
        employeeNik.setInputProperties(" size=\"12\"");
        employeeNik.setRequired(true);
        employeeNik.setInputCase(Field.CASE_UPPER);
        getFields().add(employeeNik);

        employeeName = new Field();
        employeeName.setName("employeeName");
        employeeName.setCaption("name");
        employeeName.setListProperties(" align=\"left\" width=\"20%\" nowrap");
        employeeName.setInputProperties(" size=\"30\"");
        employeeName.setRequired(true);
        employeeName.setInputCase(Field.CASE_UPPER);
        getFields().add(employeeName);

        employeePlaceOfBirth = new Field();
        employeePlaceOfBirth.setName("employeePlaceOfBirth");
        employeePlaceOfBirth.setCaption("place of birth");
        employeePlaceOfBirth.setListProperties(" align=\"left\" width=\"15%\" nowrap");
        employeePlaceOfBirth.setInputProperties(" size=\"20\"");
        employeePlaceOfBirth.setRequired(true);
        employeePlaceOfBirth.setInputCase(Field.CASE_UPPER);
        getFields().add(employeePlaceOfBirth);

        employeeDateOfBirth = new Field();
        employeeDateOfBirth.setName("employeeDateOfBirth");
        employeeDateOfBirth.setCaption("date of birth");
        employeeDateOfBirth.setListProperties(" align=\"center\" width=\"10%\" nowrap");
        employeeDateOfBirth.setInputProperties(" size=\"10\"");
        employeeDateOfBirth.setRequired(true);
        getFields().add(employeeDateOfBirth);

        employeeAddress = new Field();
        employeeAddress.setName("employeeAddress");
        employeeAddress.setCaption("address");
        employeeAddress.setListProperties(" align=\"left\" width=\"45%\" nowrap");
        employeeAddress.setInputProperties(" rows=\"5\"cols=\"50\"");
        employeeAddress.setRequired(true);
        employeeAddress.setInputType(Field.INPUT_TEXT_AREA);
        employeeAddress.setInputCase(Field.CASE_UPPER);
        getFields().add(employeeAddress);

        employeePhone = new Field();
        employeePhone.setName("employeePhone");
        employeePhone.setCaption("phone");
        employeePhone.setListProperties(" align=\"right\" width=\"15%\" nowrap");
        employeePhone.setInputProperties(" size=\"16\"");
        employeePhone.setRequired(true);
        getFields().add(employeePhone);

        employeeEmail = new Field();
        employeeEmail.setName("employeeEmail");
        employeeEmail.setCaption("E-Mail");
        employeeEmail.setListProperties(" align=\"left\" width=\"25%\" nowrap");
        employeeEmail.setInputProperties(" size=\"30\"");
        employeeEmail.setRequired(true);
        employeeEmail.setInputCase(Field.CASE_UPPER);
        getFields().add(employeeEmail);

        fillFields();
        getFieldsUnique().add(new Field[]{employeeName});
        getFieldsAdd().remove(employeeId);
        getFieldsEdit().remove(employeeId);
        getFieldsList().remove(employeeId);
        setExportList(getClass().getResourceAsStream("EmployeeList.jasper"));
        setExport(getClass().getResourceAsStream("Employee.jasper"));

        getController().setOrder(employeeName);
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "employeeName"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();


    }
}
